<template>
  <el-container class="personalcenter">
    <el-aside width="200px">
      <el-menu :default-active="menuActive" @select="selectMenu">
        <el-menu-item
          v-for="item in menuList"
          :key="item.key"
          :index="item.key"
        >
          {{ item.title }}
        </el-menu-item>
      </el-menu>
    </el-aside>
    <el-main>
      <transition name="fade-transform" appear mode="out-in">
        <keep-alive>
          <component :is="menuActive" />
        </keep-alive>
      </transition>
    </el-main>
  </el-container>
</template>

<script>
import { mapGetters } from 'vuex'
import UserInfo from './component/UserInfo'
import ModPwd from './component/ModPwd'

const menuKeys = {
  info: 'UserInfo',
  modPws: 'ModPwd'
}

export default {
  name: 'Dashboard',
  components: {
    UserInfo,
    ModPwd
  },
  data() {
    return {
      menuKeys,
      menuActive: menuKeys.info
    }
  },
  computed: {
    ...mapGetters(['userName']),
    menuList() {
      return [
        { key: menuKeys.info, title: this.$t('personalcenter.info') },
        { key: menuKeys.modPws, title: this.$t('personalcenter.modPws') }
      ]
    }
  },
  methods: {
    selectMenu(key) {
      this.menuActive = key
    }
  }
}
</script>

<style lang="scss" scoped>
.personalcenter {
  // margin: 20px 100px;

  background: #fff;
  >>> .el-input {
    width: 220px;
    margin-right: 10px;
  }
}

.el-header {
  line-height: 40px;
  height: 40px;
  text-align: center;
  color: #000;
  font-size: 24px;
  box-shadow: 0px 1px 9px #e6e9ec;
}

.el-aside {
  height: calc(100vh - 80px);
  box-shadow: 0px 1px 9px #e6e9ec;
}
</style>
